const CommentService = require('../service/Comment.service')

class CommentController {
  async publishComment(ctx, next) {
    const userId = ctx.user.id
    const { momentId } = ctx.params
    const { content } = ctx.request.body
    const result = await CommentService.publishComment(userId, momentId, content)
    ctx.body = result
  }
  async updateComment(ctx, next) {
    const { commentId } = ctx.params
    const { content } = ctx.request.body
    const result = await CommentService.updateComment(commentId, content)
    ctx.body = result
  }
  async deleteComment(ctx, next) {
    const { commentId } = ctx.params
    const result = await CommentService.deleteComment(commentId)
    ctx.body = result
  }
  async replyComment(ctx, next) {
    // 要回复的评论的id
    const { commentId } = ctx.params
    const userId = ctx.user.id
    const { momentId, content } = ctx.request.body
    const result = await CommentService.replyComment(commentId, userId, momentId, content)
    ctx.body = result
  }
  async getCommentListByMomentId(ctx, next) {
    const { momentId } = ctx.params
    const result = await CommentService.getCommentListByMomentId(momentId)
    ctx.body = result
  }
}

module.exports = new CommentController()
